﻿using System.Collections.Generic;
using System.Linq;
using KPIS.GERP.Models.SYS;
using KPIS.GERP.Models.SYS.ViewModel;

namespace KPIS.GERP.WEB.GIMS.Class
{
    public static class GimsServiceData
    { 
        //public static MessageModalVM GetMessageModal()
        //{
        //    var data = new MessageModalVM();
        //    var currentEmpCitizen = GimsMembership.CurrentEmpCitizen;
        //    //var taskMessageService = new TempService.TempServiceClient();
        //    var regularMessageService = new MessageService.MessageServiceClient();
        //    var regularMessages = new MessageService.MessageServiceClient().SelectMessage(new Message {ToEmpId = GimsMembership.CurrentEmpId, RecordStatus = "!D"}, null).ToList();
        //    //var taskMessages = taskMessageService.GetMessageByEmployeeCitizen(currentEmpCitizen).ToList();
            
        //    data.RegularMessageRead = regularMessages.Count(o => o.MessageStatus == MessageWarningStatus.Read);
        //    data.RegularMessageUnread = regularMessages.Count(o => o.MessageStatus != MessageWarningStatus.Read);
        //    data.RegularMessageUnwarn = regularMessages.Count(o => o.MessageStatus == MessageWarningStatus.Unwarn);
        //    data.Messages = regularMessages;
        //    regularMessageService.WarnMessagesAsync(GimsMembership.CurrentEmpId);
        //    // Read = 0
        //    // Unread = 1,2
        //    // Unwarn = 1
        //    // All = 0, 1, 2
        //    //data.TaskMessageRead = taskMessages.Count(o => o.message_status == "0");
        //    //data.TaskMessageUnread = taskMessages.Count(o => o.message_status == "1" || o.message_status == "2");
        //    //data.TaskMessageUnwarn = taskMessages.Count(o => o.message_status == "1");
        //    //data.TaskMessages = taskMessages.Cast<object>().ToList();
        //    //taskMessageService.MarkAsReadAsync(currentEmpCitizen);
        //    return data;
        //}

        //// Remark new system use UserId
        //public static int CountUnReadRegularMessage()
        //{
        //    return new MessageService.MessageServiceClient().CountUnReadMessage(GimsMembership.CurrentEmpId);
        //}

        //public static int CountUnWarnRegularMessage()
        //{
        //    return new MessageService.MessageServiceClient().CountUnWarnMessage(GimsMembership.CurrentEmpId);
        //}

        //public static void WarnRegularMessage()
        //{
        //    new MessageService.MessageServiceClient().WarnMessagesAsync(GimsMembership.CurrentEmpId);
        //}

        // Remark: old system using emp_seq
        //public static int CountUnReadTaskMessage()
        //{
        //    return new TempService.TempServiceClient().GetMessageUnreadCount(GimsMembership.CurrentEmpCitizen);
        //}

        //public static int CountUnWarnTaskMessage()
        //{
        //    return new TempService.TempServiceClient().GetMessageUnwarnCount(GimsMembership.CurrentEmpCitizen);
        //}

        //public static List<message> GetMessageOfEmployee()
        //{
        //    return new TempService.TempServiceClient().GetMessageByEmployeeCitizen(GimsMembership.CurrentEmpCitizen).ToList();
        //}

        //public static List<message> GetUnreadMessageOfEmployee()
        //{
        //    var sv = new TempService.TempServiceClient();
        //    var allMessageOfEmployee = sv.GetMessageByEmployeeCitizen(GimsMembership.CurrentEmpCitizen).ToList();
        //    sv.MarkAsReadAsync(GimsMembership.CurrentEmpCitizen);
        //    return allMessageOfEmployee;
        //}
    }
}
